package midend.IR_Instruction;

import midend.IR_Value.IR_BaseBlock;
import midend.IR_Value.IR_Value;
import midend.User;

import java.util.List;

public abstract class Instruction extends User{
    private List<IR_Value> op;
    private IR_BaseBlock bb;

    public Instruction(List<IR_Value> op, IR_BaseBlock bb) {
        this.op = op;
        this.bb = bb;
    }

    public void setOp(List<IR_Value> op) {
        this.op = op;
    }

    public List<IR_Value> get_op() {
        return op;
    }

    public IR_Value get_op_index(int index) {
        return op.get(index);
    }

    public IR_BaseBlock get_bb() {
        return bb;
    }

    public void set_Op(int index, IR_Value newValue) {
        op.set(index, newValue);
    }

    public void set_bb(IR_BaseBlock newbb) {
        bb = newbb;
    }


    //从其所属的基本块中删除指令
    public void remove() {
        this.get_bb().get_Instruction_List().remove(this);
    }

    public void removewithvalue() {
        removeUseOfValue();
        this.get_bb().get_Instruction_List().remove(this);
    }

    public Instruction clone(IR_BaseBlock block) {
        return null;
    }
}
